package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.MeettingRoom;
import com.ruoyi.system.mapper.MeettingRoomMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.MeetingAppointmentMapper;
import com.ruoyi.system.domain.MeetingAppointment;
import com.ruoyi.system.service.IMeetingAppointmentService;

/**
 * 会议预约表Service业务层处理
 *
 * @author ruoyi
 * @date 2023-10-17
 */
@Service
public class MeetingAppointmentServiceImpl implements IMeetingAppointmentService
{
    @Autowired
    private MeetingAppointmentMapper meetingAppointmentMapper;
    @Autowired
    private MeettingRoomMapper meettingRoomMapper;

    /**
     * 查询会议预约表
     *
     * @param id 会议预约表主键
     * @return 会议预约表
     */
    @Override
    public MeetingAppointment selectMeetingAppointmentById(Long id)
    {
        return meetingAppointmentMapper.selectMeetingAppointmentById(id);
    }

    /**
     * 查询会议预约表列表
     *
     * @param meetingAppointment 会议预约表
     * @return 会议预约表
     */
    @Override
    public List<MeetingAppointment> selectMeetingAppointmentList(MeetingAppointment meetingAppointment)
    {
        List<MeetingAppointment> meetingAppointments = meetingAppointmentMapper.selectMeetingAppointmentList(meetingAppointment);
        for (MeetingAppointment appointment : meetingAppointments) {
            MeettingRoom meettingRoom = meettingRoomMapper.selectMeettingRoomById(appointment.getMeettingId());
            appointment.setMeettingRoom(meettingRoom);
        }
        return meetingAppointments;
    }

    /**
     * 新增会议预约表
     *
     * @param meetingAppointment 会议预约表
     * @return 结果
     */
    @Override
    public int insertMeetingAppointment(MeetingAppointment meetingAppointment)
    {
        return meetingAppointmentMapper.insertMeetingAppointment(meetingAppointment);
    }

    /**
     * 修改会议预约表
     *
     * @param meetingAppointment 会议预约表
     * @return 结果
     */
    @Override
    public int updateMeetingAppointment(MeetingAppointment meetingAppointment)
    {
        return meetingAppointmentMapper.updateMeetingAppointment(meetingAppointment);
    }

    /**
     * 批量删除会议预约表
     *
     * @param ids 需要删除的会议预约表主键
     * @return 结果
     */
    @Override
    public int deleteMeetingAppointmentByIds(Long[] ids)
    {
        return meetingAppointmentMapper.deleteMeetingAppointmentByIds(ids);
    }

    /**
     * 删除会议预约表信息
     *
     * @param id 会议预约表主键
     * @return 结果
     */
    @Override
    public int deleteMeetingAppointmentById(Long id)
    {
        return meetingAppointmentMapper.deleteMeetingAppointmentById(id);
    }
}
